package com.dbky.alg.browser;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.stereotype.Repository;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @Auther: tianchao
 * @Date: 2021/12/11 15:39
 * @Description:
 */
public class ResponseUtils {

    public static ObjectMapper objectMapper = new ObjectMapper();

    public static void out(HttpServletResponse response,ApiResult apiResult) throws IOException {
        response.setContentType("utf-8");
        response.setContentType("application/json; charset=utf-8");
        PrintWriter writer = response.getWriter();
        writer.write(objectMapper.writeValueAsString(apiResult));
    }
}
